<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title>Hello MUI</title>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<link rel="stylesheet" href="../../css/mui.min.css">
		<style>
			html,
			body {
				background-color: #efeff4;
			}
			.title {
				padding: 5px 15px 5px;
				color: #6d6d72;
				font-size: 15px;
				background-color: #fff;
			}
		</style>
		
	</head>

	<body id="appHome">
		
		
		<div id="pullrefresh" class="mui-content mui-scroll-wrapper">
			<div class="mui-scroll">
				
				<ul class="mui-table-view mui-table-view-chevron">
					
						 
					<div class="mui-card"  v-for="order in rsPrds"  @click="procOrder(order.id)">
						<div class="mui-card-header" style="background-color: deepskyblue;color: white;"></div>
						<div class="mui-card-content">
							<div class="mui-card-content-inner">
								<table border=0 width="100%" height="100%">
									<tr>
										<td align="left">餐厅:</td>
										<td>{{order.work_name}}</td>
										<td align="right"></td>
										<td></td>
									</tr>
									
								</table>
								
								
								
								<table border=0 width="100%" height="100%">
									<tr  v-for="de in order.detail">
										<td align="left" width="57%">{{de.goods_name|cutString 10}}</td>
										<td align="left" width="5%">{{de.buy_count}}份</td>
										<td align="right" width="10%">¥:{{de.goods_price|cutDadixPoint 2}}</td>
										<td align="right" width="18%">总价:</td>
										<td align="right" width="10%">¥:{{de.goods_price*de.buy_count|cutDadixPoint 2}}</td>
									</tr>
									
									<tr style="border-bottom:deepskyblue solid 1px;  background-color:#ffffff;">
										<td align="left" colspan="3"></td>
										<td align="right" width="18%">合计:</td>
										<td align="left">{{order.amount|cutDadixPoint 2}}</td>
									</tr>
								</table>
								
								<table border=0 width="100%" height="100%">
									<tr>
										<td align="left" width="35%">配送:{{order.express_company_name}}</td>
										<td align="right">电话:{{order.express_company_tel}}
											<input type="button" value="结算"/>
										</td>
									</tr>
								</table>
							</div>
						</div>

					</div>
						 
					
				</ul>
			</div>
		</div>
		
		
		
		
		<script src="../../js/mui.min.js"></script>
		<script src="../../js/vue.min.js"></script>
		<script src="../../js/vuetools.js"></script>
		<script src="../../js/tools.js"></script>
		
		<script>
		var m_curOrder;	
		
		mui.init();
		
		function getWorkData(p_data)
		{
			var aryOrders = [];
			//debugger;
			for(var i=0;i<p_data.length;i++)
			{
				var objCart = p_data[i];
				var strWorkId = objCart.work_id;
				
				var bHas = false;
				var curOrder = null;
				for(var iOrd=0;iOrd<aryOrders.length;iOrd++)
				{
					curOrder = aryOrders[iOrd]; 
					if(curOrder.work_id == strWorkId)
					{
						bHas = true;
						break;
					}
				}
				
				if(bHas)
				{
					curOrder.detail.push({
							buy_count:objCart.buy_count,
							goods_id:objCart.goods_id,
							id:objCart.id,
							goods_name:objCart.goods_name,
							goods_price:objCart.goods_price
						});
					curOrder.amount += objCart.goods_price*objCart.buy_count;	
				}
				else
				{
					aryOrders.push({
					work_id:strWorkId,
					work_name:objCart.work_name,
					order_total:0,
					remark:"",
					address:"",
					consignee:"",
					mobile:"",
					expressamount:0,
					booktime:"",
					amount:objCart.goods_price*objCart.buy_count,
					detail:[{
						buy_count:objCart.buy_count,
						goods_id:objCart.goods_id,
						id:objCart.id,
						goods_name:objCart.goods_name,
						goods_price:objCart.goods_price
						}]
					});
				}
			}
			
			return aryOrders;
		}	
		
		</script>
		
		<script>
	var theVue = new Vue(
	{
	  el: '#appHome',
	  created:function()
	  {
	  	this.loadOrders();
	  },
	  data: {
	  	iCurPageNo:1,
	  	m_iPageCount:1,
	    rsPrds:[]
	  },
	  methods:
	  {
	  	
		  loadOrders:function()
		  {
		  	//var thePrds = this;
			sespost('/zdm/AppApi/ShopCart/GetMyGoodsInCart',
				{},
				function(data)
				{
					var objOrders = getWorkData(data);
					debugger;
					for(var i=0;i<objOrders.length;i++)
					{
						theVue.rsPrds.push(objOrders[i]);
					}
					
				}
			);

		  }
	  }
	});

	</script>
	</body>

</html>